﻿using System;

namespace HW0310_2
{
    class Program
    {
        static int GetMax(int[] a)
        {
            if (a == null)
                throw new Exception("error: empty array");
            int max = a[0];
            for (int i = 1; i <a.Length; i++)
            {
                if (a[i] > max)
                    max = a[i];
            }
            return max;
        }

        static int GetMin(int[] a)
        {
            if (a == null)
                throw new Exception("error: empty array");
            int min = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if (a[i] < min)
                    min = a[i];
            }
            return min;
        }
        static double GetAverage(int[] a)
        {
            if (a == null)
                throw new Exception("error: empty array");
            double sum = 0;
            for (int i = 0; i < a.Length; i++)
            {
                sum += a[i];
            }
            return sum / a.Length;
        }
        static int GetSum(int[] a)
        {
            if (a == null)
                throw new Exception("error: empty array");
            int sum = 0;
            for (int i = 0; i < a.Length; i++)
            {
                sum += a[i];
            }
            return sum;
        }
        static void Main()
        {
            Console.WriteLine("The input array is: ");
            int[] a = new int[10];
            Random r = new Random();
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = r.Next(1,50);
                Console.Write(a[i]+" ");
            }
            Console.Write("\n");
            Console.WriteLine("The maximum of it is: " + Program.GetMax(a));
            Console.WriteLine("The minimum of it is: " + Program.GetMin(a));
            Console.WriteLine("The average of it is: " + Program.GetAverage(a));
            Console.WriteLine("The sum of it is: " + Program.GetSum(a));
        }
    }
}